package com.example.aaaaa.attribute;

import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;

public class AttInfo implements Parcelable {
	String attName;
	String typeName;
	Object value;
	List<AttInfo> complexAtt;

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {

		dest.writeString(attName);
		dest.writeString(typeName);
		if (complexAtt == null) {
			dest.writeValue(value);
		} else {
			dest.writeValue(null);
			int len = complexAtt.size();
			for (int i = 0; i < len; i++) {
				AttInfo subAtt = complexAtt.get(i);
				subAtt.writeToParcel(dest, flags);
			}
		}

	}

	public static final Parcelable.Creator<AttInfo> CREATOR = new Parcelable.Creator<AttInfo>() {
		public AttInfo createFromParcel(Parcel in) {
			AttInfo attInfo = new AttInfo();
			attInfo.attName = in.readString();
			attInfo.typeName = in.readString();
			attInfo.value = in.readValue(null);
			if (attInfo.value != null) {
				attInfo.complexAtt = null;
			} else {
				Parcel subParcel = (Parcel) in.readValue(null);
				createFromParcel(subParcel);
			}
			return attInfo;
		}

		public AttInfo[] newArray(int size) {
			return new AttInfo[size];
		}
	};
}
